package org.windblog.core.servlet.link;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.windblog.core.LinkService;
import org.windblog.core.entity.Link;

@SuppressWarnings("serial")
public class DeleteLinkServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String key = request.getParameter("link");
		Link lk = LinkService.getLink(key);
		if(lk==null)
		{
			response.sendRedirect("/admin/linkManager.jsp?message=3");
		}else{
			LinkService.deleteLink(lk);
			response.sendRedirect("/admin/linkManager.jsp?message=4");
		}


	}
	
}